package com.birdboot.test;


/**
 * URLDecoder类可以将一个含有%XX的内容进行解码替换
 * 以此来解决浏览器传递中文的问题
 */

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class URLDecoderDemo {
    public static void main(String[] args) {
        String line = "范";
        byte[] t = line.getBytes(StandardCharsets.UTF_8);
        System.out.println(Arrays.toString(t));



        line = "/loginUser?username=%E8%8C%83%E4%BC%A0%E5%A5%87&password=123456";
        try {
            line = URLDecoder.decode(line,"UTF-8");
            System.out.println(line);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

    }
}
